﻿using System;
using Apache.NMS;

namespace Reactor.Messaging.ServiceBus
{
    /// <summary>
    /// Interface to define the external contract of a specific NMS implementation.
    /// </summary>
    public interface INmsGateway
    {
        /// <summary>
        /// Starts this instance by creating an <seealso cref="IConnection"/> and starting it.
        /// </summary>
        void Startup();

        /// <summary>
        /// Shuts down this instance by closing the underlying JMS Connection.
        /// </summary>
        void Shutdown();

        /// <summary>
        /// Attempts to delete the specified MessagingChannel. If the MessagingChannel was successfully deleted, a <c>true</c> value 
        /// is returned. If not, <c>false</c> is returned. A possible reason for failure is if the MessagingChannel currently 
        /// has attached consumers.
        /// </summary>
        /// <param name="messagingChannel">The MessagingChannel.</param>
        /// <returns><c>true</c> if the MessagingChannel was successfully deleted. <c>false</c> if the deletion failed.</returns>
        bool DeleteDestination(IMessagingChannel messagingChannel);

        /// <summary>
        /// Factory method to create and get a new JMS Session instance.
        /// </summary>
        /// <returns></returns>
        ISession GetSession();

        /// <summary>
        /// Occurs when the unerlying connection is interrupted.
        /// </summary>
        event EventHandler ConnectionInterrupted;
    }
}
